#include <logbase.h>
#include <queBase.h>
#include <genrand.h>



#define QUEUE_CHECK_SIZE 140
#define QUE_READ_CHEANAL 1
int main(int argc, char **argv)
{
    srand(time(NULL));//产生随机数需要使用srand初始化，不然每次运行都一样的随机数。
    static uint8_t tmpQue[QUEUE_CHECK_SIZE];
    int tmpflag = 0;
    char tmpinput[12] = {0};
    char tmpread[5] = {0};
    //将全局字符串用来做队列的缓存区。
    queOptInit(tmpQue, sizeof(tmpQue), 5);

    for(int i = 0; i < 10; i++)
    {
        genRandStrNorm(tmpinput, sizeof(tmpinput) - 1);
        logdebugc("input:%s", tmpinput);
        queOptWrite(tmpQue, (uint8_t *)tmpinput, sizeof(tmpinput) - 1);
        logdebugc("%d", queOptSize(tmpQue, QUE_READ_CHEANAL));
        tmpflag = queOptRead(tmpQue, QUE_READ_CHEANAL, (uint8_t *)tmpread, sizeof(tmpread) - 1);
        if(tmpflag > 0)
        {
            logdebugc("read:%s", tmpread);
        }
    }

    logdebugc("pop leave data--------------------->%d", queOptSize(tmpQue, QUE_READ_CHEANAL));

    while(tmpflag = queOptRead(tmpQue, QUE_READ_CHEANAL, (uint8_t *)tmpread, sizeof(tmpread) - 1), tmpread[tmpflag] = '\0', tmpflag > 0)
    {
        logdebugc("read = %s", tmpread);
    }

    return 1;
}


